package com.aidex.biz.service.impl;

import com.aidex.biz.domain.ShoppingCar;
import com.aidex.biz.mapper.ShoppingCarMapper;
import com.aidex.biz.service.ShoppingCarService;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.common.utils.NumberUtils;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 购物车Service业务层处理
 * @author sean
 * @email 2074844820@qq.com
 * @date 2023-07-02
 */
@Service
@Transactional(readOnly = true)
public class ShoppingCarServiceImpl extends BaseServiceImpl<ShoppingCarMapper, ShoppingCar> implements ShoppingCarService
{
    private static final Logger log = LoggerFactory.getLogger(ShoppingCarServiceImpl.class);

    /**
     * 获取单条数据
     * @param shoppingCar 购物车
     * @return 购物车
     */
    @Override
    public ShoppingCar get(ShoppingCar shoppingCar)
    {
        ShoppingCar dto = super.get(shoppingCar);
        return dto;
    }

    /**
     * 获取单条数据
     * @param id 购物车id
     * @return 购物车
     */
    @Override
    public ShoppingCar get(String id)
    {
        ShoppingCar dto = super.get(id);
        return dto;
    }


    /**
     * 查询购物车列表
     * @param shoppingCar 购物车
     * @return 购物车
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public List<ShoppingCar> findList(ShoppingCar shoppingCar)
    {
        return super.findList(shoppingCar);
    }

    /**
     * 分页查询购物车列表
     * @param shoppingCar 购物车
     * @return 购物车
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public PageInfo<ShoppingCar> findPage(ShoppingCar shoppingCar)
    {
        return super.findPage(shoppingCar);
    }

    /**
     * 保存购物车
     * @param shoppingCar
     * @return 结果
     */
    @Override
    public boolean save(ShoppingCar shoppingCar)
    {
        return super.save(shoppingCar);
    }


    /**
     * 删除购物车信息
     * @param shoppingCar
     * @return 结果
     */
    @Override
    public boolean remove(ShoppingCar shoppingCar)
    {
        return super.remove(shoppingCar);
    }

    /**
     * 批量删除购物车
     * @param ids 需要删除的购物车ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteShoppingCarByIds(String[] ids)
    {
        return mapper.deleteShoppingCarByIds(ids);
    }

    /**
     * 获取最大编号
     * @param shoppingCar 购物车
     * @return 结果
     */
    @Override
    public int findMaxSort(ShoppingCar shoppingCar)
    {
        return NumberUtils.nextOrder(mapper.findMaxSort(shoppingCar));
    }


    /**
     * 根据IDS查询信息
     */
    public List<ShoppingCar> findListByIds(String[] ids){
       return mapper.findListByIds(ids);
    }
}
